line = int(input())
list1 = [[] for i in range(line)]
for i in range(line):
    list1[i] = list(map(int,input().strip().split()))

maxlist = [[0 for j in range(i+1) ] for i in range(line)]

for i in range(line):
    for j in range(i+1):
        if j == 0:
            maxlist[i][j]= maxlist[i-1][j]+list1[i][j]
        elif j == i:
            maxlist[i][j] = maxlist[i-1][j- 1]+list1[i][j]
        else:
            maxlist[i][j] = max(maxlist[i-1][j],maxlist[i-1][j-1])+list1[i][j]

print(max(maxlist[line-1]))

